/**
 * Created by  on 2017/8/30.
 */

var ErpInfoViewer = {

    currentViewErpInfoId: 0,//当前显示企业信息Id

    /**
     * 加企业详情信息
     * @param id
     */
    loadErpInfoDetail: function (id) {
        ErpInfoViewer.currentViewErpInfoId = id;

        var selector = "#page_erpinfo_detail";

        function callback(data, status, xhr) {
            if (status == "success") {
                $(selector).empty();
                $(selector).html(data);
                ErpInfoViewer.showPageErpInfoDetail();
            } else {
                $(selector).html("错误信息: <br/>" + xhr.status + " " + xhr.statusText)
            }
        }

        var url = "/smAdmin/enterprise/erpinfo_detail?id=" + id;
        // 请求编辑框的页面数据库
        $.get(url, "", callback);
    },

    /**
     * 显示企业列表信息
     */
    showPageErpInfoList: function () {
        $('#page_erpinfo_list').show();
        $('#page_erpinfo_detail').hide();
        //ErpInfoViewer.reloadErpInfoList();
    },

    /**
     * 显示企业详情信息
     */
    showPageErpInfoDetail: function () {
        $('#page_erpinfo_list').hide();
        $('#page_erpinfo_detail').show();
    },

    /**
     * 重新加载企业列表信息
     */
    reloadErpInfoList: function () {
        var filters = {"groupOp": "AND", "rules": []};
        var rules = filters.rules;
        var args = formserializeJson("erpinfo_list_form");
        for (var name in args) {
            var value = args[name];
            if (value) {
                rules.push({field: name, op: "cn", data: value});
            }
        }

        var postData = $("#erpinfo-grid-table").jqGrid("getGridParam", "postData");
        $.extend(postData, {filters: JSON.stringify(filters)});
        $("#erpinfo-grid-table").jqGrid("setGridParam", {search: true}).trigger("reloadGrid", [{page: 1}]);  //重载JQGrid
    },

    // 创建新对象
    createNew: function () {
        var Checker = {};
    },

};